package com.woniuxy.hrp.web;

import com.woniuxy.hrp.entity.Wallet;
import com.woniuxy.hrp.service.WalletService;
import com.woniuxy.hrp.unityhandler.ResponseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description：
 * @Author：曹杰克
 * @CreateTime：2022/8/30 15:36
 */
@Transactional
@CrossOrigin
@RestController
@RequestMapping("/api/v1/wallet")
public class WalletController {
    @Autowired
    WalletService walletService;
    /**
     * 查询钱包信息根据患者id
     * @param patientId
     * @return
     */
    @RequestMapping("/getWallet")
    public ResponseEntity getByPatientId(int patientId){
        Wallet wallet = walletService.getByPatientId(patientId);
        return new ResponseEntity("200","ok",wallet);
    }

    /**
     * 对余额进行增减
     * @param wallet
     * @return
     */
    @PostMapping("/updateWallet")
    public ResponseEntity updateWallet(Wallet wallet){
        walletService.updateWallet(wallet);
        return  ResponseEntity.SUCCESS;
    }

}
